package com.wechat.server.mp.config;

import com.pdd.pop.sdk.http.PopClient;
import com.pdd.pop.sdk.http.PopHttpClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @description: 配置类
 * @author: stone
 * @date: Created by 2021/10/10 11:26
 * @version: 1.0.0
 * @pakeage: com.wechat.server.mp.config
 */
@Configuration
public class PddConfig {

    public static Map<String, Object> cacheToken = new ConcurrentHashMap<>(4);
    //
    //public static String access_token = "89574a64ad0d4f1898e24c6308a275b50815870d";
    //public static String refresh_token = "aa1f0287c09048bab8ec5cfab5d8f7ee7e581e5b";

    //        PopClient client = new PopHttpClient(client_id, client_secret);
    @Bean
    public PopClient popClient(PddConfig.PddProperties properties) {
        return new PopHttpClient(properties.getClientId(), properties.getClientSecret());
    }


    @Data
    @ConfigurationProperties(prefix = "pdd.wechat.config")
    @Component
    public static class PddProperties {

        private String clientId;

        private String clientSecret;

        private String authUrl;

        private String clientUrl;


    }


}
